package com.maliankeji.mybatisflexdemo.service.impl;



import org.springframework.stereotype.Service;
import com.maliankeji.mybatisflexdemo.service.UserInfoService;
import com.maliankeji.mybatisflexdemo.entity.UserInfo;
import com.maliankeji.mybatisflexdemo.mapper.UserInfoMapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;

import javax.annotation.Resource;
import java.util.List;

/**
 * 服务层实现。
 *
 * @author mybatis-flex-helper automatic generation
 * @since 1.0
 */
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService {

    @Resource
    private UserInfoMapper userInfoMapper;

    @Override
    public int addUser(UserInfo userInfo) {
        if (null == userInfo.getPassword() || userInfo.getPassword().isEmpty())
            return 0;
        return userInfoMapper.insert(userInfo);
    }

    @Override
    public int deleteUser(UserInfo userInfo) {
        return userInfoMapper.delete(userInfo);
    }

    @Override
    public int updateUser(UserInfo userInfo) {
        return userInfoMapper.update(userInfo);
    }

    @Override
    public List<UserInfo> getAllUserInfo() {
        return userInfoMapper.selectAll();
    }

    @Override
    public UserInfo getUserInfoById(int id) {
        return userInfoMapper.selectOneById(id);
    }
}